﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AutoGear.BLL;
using Entity;
using ECommerce.DAL;


public partial class admin_quick_print : SiteAdminBasePage
{
  

    protected void Page_Load(object sender, EventArgs e)
    {
        ProductPurchaseOrder orders = new ProductPurchaseOrder();
        if (!Page.IsPostBack)
        {
            List<string> idList = new List<string>();
            if (Session["PrintOrderList"] != null)
            {
                //casting line below
                idList = (List<string>)Session["PrintOrderList"];
                for (int i = 0; i < idList.Count; i++)
                {
                    orders = ProductPurchaseOrder.Load(Convert.ToInt32(idList[i]));
                    if (orders != null)
                    {
                        if (hdnOrderId.Value.Length > 0)
                            hdnOrderId.Value = hdnOrderId.Value + ",";
                        if (orders.IsMultipleShip == true)
                        {
                            CustomCollection<TblProductPurchaseOrder_MultipleShippingInfo> shippings = TblProductPurchaseOrder_MultipleShippingInfo.GetTblProductPurchaseOrder_MultipleShippingInfoByOrderId(orders.OrderId);
                            if (shippings != null)
                            {
                                hdnOrderId.Value = hdnOrderId.Value + shippings[0].OrderId;
                                for (int j = 0; j < shippings.Count; j++)
                                {
                                    hdnOrderId.Value = hdnOrderId.Value + ":" + shippings[j].ProductPurchaseOrder_MultipleShippingInfoId;
                                }
                            }
                        }
                        else
                        {
                            hdnOrderId.Value = hdnOrderId.Value + orders.OrderNumber;
                        }

                    }

                }
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "_showblockui", "OpenWindow();", true);
            }
            else
            {
                Response.Redirect(AutoGear.BLL.CustomSiteMap.SalesCCSuccess);
            }
        }
    }
}